﻿using System;
using System.Collections.Generic;

namespace JSONHelpers
{
    public class JSONObject : List<JSONField>
    {
        public static readonly JSONObject Empty = new JSONObject();

        public JSONObject (params JSONField[] fields)
        {
            AddRange (fields);
        }

        public override string ToString ()
        {
            List<string> sfields = new List<string>();

            foreach (JSONField field in this)
                sfields.Add (field.ToString());

            return "{" + string.Join(",", sfields.ToArray()) + "}";
        }
    }
}

